package com.woniuxy.oldobject.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.oldobject.dao.NursingProjectDao;
import com.woniuxy.oldobject.entity.NursingProject;
import com.woniuxy.oldobject.service.NursingProjectService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

/**
 * 护理项目(NursingProject)表服务实现类
 *
 * @author makejava
 * @since 2022-07-28 18:16:06
 */
@Service("nursingProjectService")
public class NursingProjectServiceImpl extends ServiceImpl<NursingProjectDao, NursingProject> implements NursingProjectService {
    @Resource
    private NursingProjectDao nursingProjectDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public NursingProject queryById(Integer id) {
        return this.nursingProjectDao.queryById(id);
    }

    @Override
    public List<NursingProject> queryAll() {
        return nursingProjectDao.queryAll();
    }

    /**
     * 新增数据
     *
     * @param nursingProject 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(NursingProject nursingProject) {
        nursingProject.setCreateTime(new Date());
        nursingProject.setUpdateTime(new Date());
        int i = nursingProjectDao.insert(nursingProject);
        return i;
    }

    /**
     * 修改数据
     *
     * @param nursingProject 实例对象
     * @return 实例对象
     */
    @Override
    public int update(NursingProject nursingProject) {
        int i = nursingProjectDao.update(nursingProject);
        return i;
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.nursingProjectDao.deleteById(id) > 0;
    }
}